<?php
require_once 'config.inc.php'; 
if (empty($_SESSION["username"])){
	header("Location:./admin/login.php");
}
$uid = $_SESSION["uid"];
if ($_GET['id']) {
	$id = intval($_GET['id']);	
	$sql = "SELECT * FROM {$tablepre}adds WHERE id = $id AND uid='$uid'";
	$result=mysql_query($sql); 
	$adds = mysql_fetch_array($result,MYSQL_ASSOC);
}else{

	$sql = "SELECT * FROM {$tablepre}adds WHERE uid='$uid'";
	$result=mysql_query($sql); 
	while($add = mysql_fetch_array($result,MYSQL_ASSOC)){
	
	$adds[] = $add;
	}
	
}
?>
<a href="admin/admin_adds.php">新建联系人</a>  新建组 <a href="/admin/admin_channel.php" target="_blank">新建目录</a>


<link rel="stylesheet" type="text/css" href="images/style.css">
<?php if ($_GET['id']) {?>
<div class="note">
	<div class="title">
	标题:<?php echo  $adds['who'] ?>
	<a href="admin/admin_adds.php?id=<?php echo $adds[id] ?>">[编辑]</a> <a href="admin/admin_adds.php?action=del&amp;id=<?php echo $adds[id] ?>" onclick="return confirm('Are you sure you want to delete?')">[删除]</a></div>
  <div class="content">
	<?php
	foreach($adds as $key=>$value){
	 printf("<strong>%s:</strong> %s <br>\n",$key,$value);
	}
	
	?>
	</div>
	<a href="admin/admin_adds.php?id=<?php echo $adds[id] ?>" >[编辑]</a>
</div>
<?php }else{ ?>
<div class="note">
	<div class="title">
	通讯录
	</div>
	<div class="content">
	<?php
	foreach($adds as $key=>$value){
		$line=array();
		foreach($value as $key1=>$value1){
			if ($key1 != 'id'&&$key1 != 'gid'&&$key1 != 'cid'&&$key1 !='displayid' &&!empty($value1)){
				switch($key1){
				case 'who':$key1='姓名'; break;
				case 'xiao':$key1='小灵通'; break;
				case 'mobile':$key1='手机'; break;
				case 'office':$key1='办公'; break;
				case 'home':$key1='家庭'; break;
				}
			
			$line[]= sprintf("<strong>%s:</strong> %s",$key1,$value1);
			}
			
		}
		echo implode(",",$line); 
		echo "\n<br>";
	}
	
	?>
	</div>

<?
}
require_once 'foot.inc.php';
?>

 